﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace MLog.Core.Fliter {
    public class PlatformFilter : BaseFilter<LoggerEvent> {
        private List<RuntimePlatform> Platforms { set; get; }

        public override bool Decide(LoggerEvent @event) {
            return Platforms != null && Platforms.Contains(Application.platform);
        }

        protected override bool CustomApply(Node property) {
            if ("platform".Equals(property.Name)) {
                var value                        = property.Value;
                if (Platforms == null) Platforms = new List<RuntimePlatform>();
                Platforms.Add((RuntimePlatform) Enum.Parse(typeof(RuntimePlatform), value, true));
                return true;
            }

            return false;
        }
    }
}